#include <stdio.h>
#include <stdlib.h>
#define N  100

int     a[N][N];
int     n;

#pragma instrument function (Init, Magique, Lire, Print, main)

void Init (int n)
{
    int i, j;

    for (i = 0 ; i < n; ++i)
        for (j = 0; j < n; ++j)
            a[i][j] = 0;
}

void Magique (int n)
{
    int i, j, k;
		
		printf("n vaut %d\n", n);

		//printf("nbit vaut %d\n", nbit);		

    i = n - 1; j = n / 2;
		int nbit = n*n;    
    for (k = 1; k <= nbit; ++k) {
        a[i][j] = k;
        if ((k % n) == 0)
            i = i - 1;
        else {
            i = (i + 1) % n; 
            j = (j + 1) % n;
        }
    }
}

void Erreur (char s[])
{
    printf ("Erreur fatale: %s\n", s);
    exit(1);
}

void Lire (int *n)
{
    /*printf ("Taille du carre' magique, svp?::  ");
    scanf ("%d", n);*/
    *n=15;
    if ((*n <= 0) || (*n > N) || (*n % 2 == 0)) 
        Erreur ("Taille impossible.");
}

void Print (int n)
{
    int i, j;

    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) 
            printf ("%4d ", a[i][j]);
        printf ("\n");
    }
}

int main ()
{
    Lire(&n);
    Init(n);       /* - */
    Magique(n);
    Print(n);
    return 0;
}
